<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Mod_content extends CI_Controller {
	function __construct() {
		parent::__construct();
	}
	function index() {
		$data['setting']         = $this->common_model->getone('setting', array(
			'id' => 1
		));
		$data['about']           = $this->common_model->getdata('about', array(
			'publish' => 1
		), '', array(
			'id',
			'DESC'
		), 3);
		$data['hightlight']      = $this->common_model->getdata('hightlight', array(
			'publish' => 1
		), '', array(
			'id',
			'DESC'
		), 15);
		$data['tinh']            = $this->common_model->getdata('province', '', array(
			'id',
			'title'
		), array(
			'order',
			'ASC'
		));
		$data['menu_monhoc']     = $this->load->controller('mod_menu/mod_menu/object_nav');
		$data['provine']         = $this->common_model->getdata('province', '', array(
			'id',
			'title'
		), array(
			'order',
			'ASC'
		));
		$data['numstudent']      = $this->common_model->getnumber2('users', array(
			'type' => 0
		));
		$data['intro']           = $this->common_model->getdata('intro_index', array(
			'publish' => 1
		), '', array(
			'order',
			'ASC'
		), 4);
		$data['reviews_student'] = $this->common_model->getdata('reviews', array(
			'publish' => 1,
			'featured' => 1,
			'type' => 0
		), '', array(
			'order',
			'ASC'
		), 5);
		$data['reviews_tutor']   = $this->common_model->getdata('reviews', array(
			'publish' => 1,
			'featured' => 1,
			'type' => 1
		), '', array(
			'order',
			'ASC'
		), 5);
		foreach ($data['hightlight'] as $hightlight) {
			$data['users'][] = $this->common_model->getone('users', array(
				'id' => $hightlight->usrid
			));
		}
		return $this->load->view('mod_content/view_content.php', $data, true);
	}
	
	function districts() {
		$thanhpho  = $_POST["province"];
		$quanhuyen = $this->common_model->getdata('district', array(
			'prvid' => $thanhpho
		), array(
			'id',
			'title'
		), array(
			'order',
			'ASC'
		));
		if (!empty($quanhuyen)) {
			foreach ($quanhuyen as $qh):
				echo '<option value="' . $qh->id . '">-- ' . $qh->title . ' --</option>';
			endforeach;
		} else {
			echo '<option value="0">-- Không có dữ liệu --</option>';
		}
		
	}
}
?>